override OPTS += -lpthread
CDIR=../../../..
CHARMC=$(CDIR)/bin/charmc $(OPTS)

MODULE=CkLoop
LIB = $(CDIR)/lib/libmodule$(MODULE).a
LIBOBJ = CkLoop.o

CIFILES = CkLoop.ci
HEADERS = CkLoopAPI.h CkLambda.h $(MODULE).decl.h $(MODULE).def.h

all: $(LIB)  headers

$(LIB): $(LIBOBJ)
	$(CHARMC) -o $(LIB) $(LIBOBJ) 

headers: $(HEADERS)
	cp $(HEADERS) $(CDIR)/include/

$(MODULE).def.h: $(MODULE).decl.h

$(MODULE).decl.h: CkLoop.ci
	$(CHARMC) -c $<

clean:
	rm -f *.o *.decl.h *.def.h $(LIB) headers

include Make.depends

DEPENDFILE = Make.depends

depends:  $(CIFILES) CkLoop.def.h
	echo "Creating " $(DEPENDFILE) " ..."; 	\
	if [ -f $(DEPENDFILE) ]; then \
           /bin/cp -f $(DEPENDFILE) $(DEPENDFILE).old; \
        fi; \
	echo '#generated by make depends' > $(DEPENDFILE); \
        for i in $(LIBOBJ) ; do \
	      SRCFILE=`basename $$i .o`.C ; \
              echo "checking dependencies for $$i : $$SRCFILE" ; \
              g++ -MM -Wno-deprecated -I$(CDIR)/tmp $$SRCFILE >> $(DEPENDFILE); \
              echo '	$$(CHARMC) -I$(CDIR)/tmp -o '$$i $$SRCFILE >> $(DEPENDFILE) ; \
        done; 

